* ============================================================================================================================================================================================================
* Replication Do-File for PAID-Article "The Association between Agreeableness, Extraversion, and Support for Secessionist Movements: Evidence from A Large Survey of More Than 33,000 Respondents in Catalonia"
* by Joan Barcel�, 11.17.2016
* ============================================================================================================================================================================================================

use "[yourpath]\PAID_dataset.dta", clear

* ==================================================
* TABLE 1
* ==================================================

pwcorr Extroversion_item1 Extroversion_item2 Agreeableness_item1 Agreeableness_item2 Conscientiousness_item1 Conscientiousness_item2 Neuroticism_item1 Neuroticism_item2 Openess_item1 Openess_item2 [aw=zweight]

* ==================================================
* TABLE 2
* ==================================================

quietly eststo: mlogit referendum c.Zagreeableness c.Zextroversion c.Zconscientiousness c.Zneuroticism c.Zopenness age age_sq gender prov_gir prov_llei prov_tarr income1 income2 income3 income4 income5 middle_class uppermiddle_class educ1 educ2 origin_2ndGen origin_mixed origin_CAT language_motCS language_motO language_motC [pw=zweight], base(0)
est store A
quietly eststo: mlogit referendum c.Zagreeableness c.Zextroversion c.Zconscientiousness c.Zneuroticism c.Zopenness age age_sq gender prov_gir prov_llei prov_tarr income1 income2 income3 income4 income5 middle_class uppermiddle_class educ1 educ2 origin_2ndGen origin_mixed origin_CAT language_motCS language_motO language_motC ideology turnout [pw=zweight], base(0)
est store B
quietly eststo: mlogit referendum c.Zagreeableness c.Zextroversion c.Zconscientiousness c.Zneuroticism c.Zopenness age age_sq gender prov_gir prov_llei prov_tarr income1 income2 income3 income4 income5 middle_class uppermiddle_class  educ1 educ2 origin_2ndGen origin_mixed origin_CAT language_motCS language_motO language_motC ideology turnout  asCasS moreCthanS onlyC [pw=zweight], base(0)
est store C

cd "[yourpath]"
esttab A B C using table2.tex, replace f label booktabs b(3) p(3)

* ==================================================
* FIGURE 1
* ==================================================

quietly margins, at(Zagreeableness=(-3 (0.2) 3)) atmeans predict(outcome(2)) vsquish

marginsplot, recast(line) recastci(rarea) xscale(range(-2 2) titlegap(1)) addplot(hist Zagreeableness, bin(1000) percent yaxis(2) fcolor(none) lcolor(black))

graph export PlotAgree.png, width(12000) height(8000)

quietly margins, at(Zextroversion=(-3 (0.2) 3)) atmeans predict(outcome(2)) vsquish

marginsplot, recast(line) recastci(rarea) xscale(range(-2 2) titlegap(1)) addplot(hist Zextroversion, bin(1000) percent yaxis(2) fcolor(none) lcolor(black))

graph export PlotExtra.png, width(12000) height(8000)

* ==================================================
* TABLE 3
* ==================================================

mlogit referendum Extroversion_item1 Extroversion_item2 Agreeableness_item1 Agreeableness_item2 Conscientiousness_item1 Conscientiousness_item2 Neuroticism_item1 Neuroticism_item2 Openess_item1 Openess_item2 age age_sq gender prov_gir prov_llei prov_tarr income1 income2 income3 income4 income5 middle_class uppermiddle_class educ1 educ2 origin_2ndGen origin_mixed origin_CAT language_motCS language_motO language_motC ideology turnout  asCasS moreCthanS onlyC [pw=zweight], base(0)

* ==================================================
* TABLE 4
* ==================================================

quietly eststo: mlogit referendum c.Zagreeableness c.Zextroversion c.Zconscientiousness c.Zneuroticism c.Zopenness age age_sq gender prov_gir prov_llei prov_tarr income1 income2 income3 income4 income5 middle_class uppermiddle_class  educ1 educ2 origin_2ndGen origin_mixed origin_CAT language_motCS language_motO language_motC ideology turnout  asCasS moreCthanS onlyC interest_in_sec [pw=zweight], base(0)
est store C1

quietly eststo: mlogit referendum c.Zagreeableness c.Zextroversion c.Zconscientiousness c.Zneuroticism c.Zopenness age age_sq gender prov_gir prov_llei prov_tarr income1 income2 income3 income4 income5 middle_class uppermiddle_class  educ1 educ2 origin_2ndGen origin_mixed origin_CAT language_motCS language_motO language_motC ideology turnout asCasS moreCthanS onlyC economic_reasons1[pw=zweight], base(0)
est store C2

quietly eststo: mlogit referendum c.Zagreeableness c.Zextroversion c.Zconscientiousness c.Zneuroticism c.Zopenness age age_sq gender prov_gir prov_llei prov_tarr income1 income2 income3 income4 income5 middle_class uppermiddle_class  educ1 educ2 origin_2ndGen origin_mixed origin_CAT language_motCS language_motO language_motC ideology turnout  asCasS moreCthanS onlyC interest_in_sec economic_reasons1[pw=zweight], base(0)
est store C3

cd "[yourpath]"
esttab C1 C2 C3 using table4.tex, replace f label booktabs b(3) p(3)
